<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('部门列表')" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<input type="hidden" th:value="${userId}" id="userId">
				<form id="dept-form">
					<div class="select-list">
						<ul>
							<li>
								部门名称：<input type="text" name="deptName"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
       		 <div class="col-sm-12 select-table table-striped">
	            <table id="bootstrap-tree-table"></table>
	        </div>
	    </div>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var prefix = ctx + "base/sys/dept";
		/* 添加角色-提交 */
		function submitHandler(index, layero){
			debugger;
			var rows = $("#bootstrap-tree-table").bootstrapTreeTable('getSelections');
			if(rows.length==0) {
				$.modal.alertError("请至少选择一个科室");return;
			}
			var deptIds = "";
			$.each(rows,function (index,item) {
				deptIds+=item.deptId+",";
			});
			var data = { "userId": $("#userId").val(), "deptIds": deptIds.substring(0,deptIds.length-1)};
			$.operate.saveTab(ctx + "base/sys/user/authDept/insertAuthDept", data);
		}
		$(function() {
		    var options = {
		        code: "deptId",
		        parentCode: "parentId",
		        uniqueId: "deptId",
		        url: prefix + "/list",
		        modalName: "部门",
				clickToSelect: true,
				rememberSelected: true,
		        columns: [{
                    field: 'selectItem',
					checkbox: true
                 },
					{
						field: 'deptId',
						title: '主键',
					},
					{
						field: 'deptCode',
						title: 'HIS编码',
					},
                 {
		            field: 'deptName',
		            title: '部门名称',
		            align: "left"
		        },]
		    };
		    $.treeTable.init(options);
		});
	</script>
</body>
</html>